# -*- coding: utf-8 -*-
# 操作工单报表
# author： kumiler
# create_time: 2022-03-21 14:25:10


from jms.dwd.oms.dwd_yl_oms_oms_waybill_incre_dt import jms_dwd__dwd_yl_oms_oms_waybill_incre_dt
from jms.dwd.sqs.dwd_sqs_problem_express_wo_base_dt import jms_dwd__dwd_sqs_problem_express_wo_base_dt
from jms.dwd.sqs.dwd_sqs_problem_express_wo_log_base_dt import jms_dwd__dwd_sqs_problem_express_wo_log_base_dt
from jms.dim.dim_network_whole_massage import jms_dim__dim_network_whole_massage
from datetime import timedelta
from utils.operators.spark_submit import SparkSubmitOperator

jms_dm__dm_waybill_problem_express_wo_dt = SparkSubmitOperator(
    task_id='jms_dm__dm_waybill_problem_express_wo_dt',
    email=['lukunming@jtexpress.com','yl_bigdata@yl-scm.com'],
    name='dm_waybill_problem_express_wo_dt_{{ execution_date | date_add(1) | cst_ds }}',
    driver_memory='4G',
    executor_memory='16G',
    executor_cores=4,
    num_executors=10,
    pool_slots=5,
    conf={'spark.dynamicAllocation.enabled'                  : 'true',  # 动态资源开启
          'spark.shuffle.service.enabled'                    : 'true',  # 动态资源 Shuffle 服务开启
          #'spark.dynamicAllocation.maxExecutors'             : 100,  # 动态资源最大扩容 Executor 数
          'spark.dynamicAllocation.maxExecutors'             : 27,  # 动态资源最大扩容 Executor 数
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 120,  # 动态资源自动释放闲置 Executor 的超时时间(s)
          'spark.sql.sources.partitionOverwriteMode'         : 'dynamic',  # 允许删改已存在的分区
          'spark.executor.memoryOverhead'                    : '2G',  # 堆外内存
          'spark.default.parallelism'                        : 600,
          'spark.sql.shuffle.partitions'                     : 600
          },
    jars='hdfs:///scheduler/jms/spark/lkm/report/problemExpress/common-1.0-SNAPSHOT.jar',  # 依赖 jar 包
    java_class='com.yunlu.bigdata.jobs.report.problemExpress.ProblemExpressWo',  # spark 主类
    application='hdfs:///scheduler/jms/spark/lkm/report/problemExpress/original-jobs-1.0-SNAPSHOT.jar',  # spark jar 包
    application_args=['{{ execution_date | cst_ds }}'],
    execution_timeout=timedelta(minutes=15),
)

jms_dm__dm_waybill_problem_express_wo_dt << [
    jms_dwd__dwd_yl_oms_oms_waybill_incre_dt,
    jms_dwd__dwd_sqs_problem_express_wo_base_dt,
    jms_dwd__dwd_sqs_problem_express_wo_log_base_dt,
    jms_dim__dim_network_whole_massage
]
